package com.byxy.service;

import com.byxy.dao.AdministratorsDaoImpl;
import com.byxy.dao.BaseDao;
import com.byxy.model.Administrators;

import java.util.List;

public class AdministratorsServiceImpl implements BaseService<Administrators> {
	BaseDao<Administrators> adminDao = new AdministratorsDaoImpl();
	
	@Override
	public int add(Administrators admin) {
		return adminDao.add(admin);
	}

	@Override
	public int deleteById(int id) {
		return adminDao.deleteById(id);
	}

	@Override
	public int update(Administrators admin) {
		return adminDao.update(admin);
	}

	@Override
	public List<Administrators> findAll() {
		return adminDao.findAll();
	}

	@Override
	public Administrators findById(int id) {
		return adminDao.findById(id);
	}

	public boolean login(Administrators admin) {
		AdministratorsDaoImpl adminDao = new AdministratorsDaoImpl();
		return adminDao.login(admin);
	}
	
	public boolean alterPassword(String username, String oldPassword, String newPassword) {
		AdministratorsDaoImpl adminDao = new AdministratorsDaoImpl();
		return adminDao.alterPassword(username, oldPassword, newPassword);
	}
}
